So I've been trying to find a way to prevent users from modifying a module during the export process so that what we deliver is the same as what is in DOORs because someone decided "Oh shoot I need to change something just because!"
Module m = current
Object o = current
Trigger t
DB DPMenu = create ("", styleCentered | styleFloating| styleFixed)
string buttons [] = {"Add Warning", "Remove Warning", "Close"}
int answer = messageBox("Add or Remove in progress warning", buttons, msgWarning)
if (answer == 0)
{
sFunction = "warningBox(\"This module is currently being processed for export \n\n\t\t DO NOT MODIFY\")"
string tName = "RPE warning"
for t in m do
{
if(name(t) == tName) delete(t)
}
trigger(tName, module, pre ,open, 1,sFunction)
}
else if (answer == 1)
{
string dName = "RPE warning"
for t in m do
{
Name = name(t)
if(confirm("Delete trigger ["dName"]?"))
delete(t)
infoBox(dName " trigger was deleted")
}
}
else if (answer == 2)
{
halt
}
DB db
This is what I have come with so far. Currently it will allow any user who has permission to open the module in Read and no trigger will fire. As soon as they switch to Exclusive edit the trigger will fire and give them the message "This module is currently being processed for export DO NOT MODIFY" but once they confirm it will open the module in exclusive anyways. So besides relying on the honor system that they wouldn't change something anyway would it be possible to do 3 things
I'm just starting to learn Triggers so I thought something somewhat simple would be good practice. If there is a better way to do this I am always open to other ideas.
-MrNiceGuy
MrNiceGuy - Fri May 12 18:18:49 EDT 2017 |
Re: Module Trigger
Module m = current
Object o = current
Trigger t
if (isEdit m)
{
infoBox "The module must be in Read before Trigger is applied"
halt
}
else
{
DB DPMenu = create ("", styleCentered | styleFloating| styleFixed)
string buttons [] = {"Add Warning", "Remove Warning", "Close"}
int answer = messageBox("Add or Remove PRMT/CDRL in progress warning", buttons, msgWarning)
if (answer == 0)
{
sFunction = "warningBox(\"This module is currently being processed for PRMT or CDRL export. \n
If you believe this is a mistake or if you have any questions please contact a DOORS Admin.\")"
string tName = "RPE warning"
string lockM
lockM = lock(module m)
for t in m do
{
if(name(t) == tName) delete(t)
save(m)
}
trigger(tName, module, pre ,open, 1,sFunction)
}
else if (answer == 1)
{
string dName = "RPE warning"
string uLock
uLock = unlock(module m)
for t in m do
{
Name = name(t)
if(confirm("Delete trigger ["dName"]?"))
delete(t)
save(m)
infoBox(dName " trigger was deleted")
}
}
else if (answer == 2)
{
halt
}
}
So I think I figured out a way to do what I wanted. I added in the module lock when applying the trigger and the unlock to the removal of the trigger. So the only question I have is number 1 If it is possible to do a lock where Admins can still access the module or would this be the best way?
|
Re: Module Trigger MrNiceGuy - Mon May 15 19:11:54 EDT 2017
Module m = current
Object o = current
Trigger t
if (isEdit m)
{
infoBox "The module must be in Read before Trigger is applied"
halt
}
else
{
DB DPMenu = create ("", styleCentered | styleFloating| styleFixed)
string buttons [] = {"Add Warning", "Remove Warning", "Close"}
int answer = messageBox("Add or Remove PRMT/CDRL in progress warning", buttons, msgWarning)
if (answer == 0)
{
sFunction = "warningBox(\"This module is currently being processed for PRMT or CDRL export. \n
If you believe this is a mistake or if you have any questions please contact a DOORS Admin.\")"
string tName = "RPE warning"
string lockM
lockM = lock(module m)
for t in m do
{
if(name(t) == tName) delete(t)
save(m)
}
trigger(tName, module, pre ,open, 1,sFunction)
}
else if (answer == 1)
{
string dName = "RPE warning"
string uLock
uLock = unlock(module m)
for t in m do
{
Name = name(t)
if(confirm("Delete trigger ["dName"]?"))
delete(t)
save(m)
infoBox(dName " trigger was deleted")
}
}
else if (answer == 2)
{
halt
}
}
So I think I figured out a way to do what I wanted. I added in the module lock when applying the trigger and the unlock to the removal of the trigger. So the only question I have is number 1 If it is possible to do a lock where Admins can still access the module or would this be the best way?
Should just baseline the module, then export the baseline. |